#include <map>
#include <iostream>
#include <string>
using namespace std;
int main (int argc, char ** argu){

 
 map <string,int> m;

 
 string word;
 while (cin >> word){
// cout<< word<< endl;
   if (m.find(word)!=m.end())
   m[word]++;
   else
   m[word]=1;
}
map <string,int>:: iterator it=m.begin();
while (m.end()!=it){
 cout <<it->first<<" "<<it->second<< endl;
 it++;
}

 

return 0;
}
